package com.vue.controller;

import cn.hutool.json.JSONUtil;
import com.vue.entity.gpt.GPTRequest;
import com.vue.service.ChartGPTService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
/**
 * @author: wrj
 * @since: 2024/12/2 18:06
 * @description: GPT-3接口
 */

/**
 *
 *
 * @author zhengwen
 */

@Slf4j
@RestController
@RequestMapping("/chatGpt")
public class ChatGPTController {

    @Resource
    private ChartGPTService chartGPTService;

    /**
     * openAI GPT-3
     *
     * @param gptRequest 条件对象
     * @return 出参对象
     */
    @PostMapping("/askAi")
    public String askAi(@RequestBody GPTRequest gptRequest) {

        String replyStr = chartGPTService.send(gptRequest.getAskStr());

        gptRequest.setReplyStr(replyStr);

        return JSONUtil.toJsonStr(gptRequest);
    }
}


